package com.google.android.gms.ads.internal.overlay;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.ViewCompat;
import android.view.View;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import com.google.android.gms.ads.internal.zzbt;
import com.google.android.gms.common.internal.Hide;
import com.google.android.gms.common.util.zzs;
import com.google.android.gms.dynamic.IObjectWrapper;
import com.google.android.gms.dynamic.zzn;
import com.google.android.gms.internal.zzabh;
import com.google.android.gms.internal.zzahw;
import com.google.android.gms.internal.zzaij;
import com.google.android.gms.internal.zzaip;
import com.google.android.gms.internal.zzaof;
import com.google.android.gms.internal.zzlc;
import com.google.android.gms.internal.zzoi;
import com.google.android.gms.internal.zzyn;
import com.google.android.gms.internal.zzyr;
import java.util.Collections;
import java.util.Map;

@Hide
@zzabh
public class zzd extends zzyr implements zzw {
    private static int zzcmk = Color.argb(0, 0, 0, 0);
    protected final Activity mActivity;
    private zzaof zzcct;
    AdOverlayInfoParcel zzcml;
    private zzi zzcmm;
    private zzo zzcmn;
    private boolean zzcmo = false;
    private FrameLayout zzcmp;
    private WebChromeClient.CustomViewCallback zzcmq;
    private boolean zzcmr = false;
    private boolean zzcms = false;
    private zzh zzcmt;
    private boolean zzcmu = false;
    int zzcmv = 0;
    private final Object zzcmw = new Object();
    private Runnable zzcmx;
    private boolean zzcmy;
    private boolean zzcmz;
    private boolean zzcna = false;
    private boolean zzcnb = false;
    private boolean zzcnc = true;

    public zzd(Activity activity) {
        this.mActivity = activity;
    }

    private final void zznk() {
        if (this.mActivity.isFinishing() && !this.zzcna) {
            this.zzcna = true;
            if (this.zzcct != null) {
                this.zzcct.zzag(this.zzcmv);
                synchronized (this.zzcmw) {
                    if (!this.zzcmy && this.zzcct.zzuh()) {
                        this.zzcmx = new zzf(this);
                        zzaij.zzdfn.postDelayed(this.zzcmx, ((Long) zzlc.zzio().zzd(zzoi.zzbpk)).longValue());
                        return;
                    }
                }
            }
            zznl();
        }
    }

    private final void zznn() {
        this.zzcct.zznn();
    }

    private final void zzs(boolean z) {
        int intValue = ((Integer) zzlc.zzio().zzd(zzoi.zzbvb)).intValue();
        zzp zzp = new zzp();
        zzp.size = 50;
        zzp.paddingLeft = z ? intValue : 0;
        zzp.paddingRight = z ? 0 : intValue;
        zzp.paddingTop = 0;
        zzp.paddingBottom = intValue;
        this.zzcmn = new zzo(this.mActivity, zzp, this);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
        layoutParams.addRule(10);
        layoutParams.addRule(z ? 11 : 9);
        zza(z, this.zzcml.zzcnp);
        this.zzcmt.addView(this.zzcmn, layoutParams);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:44:0x00ce, code lost:
        if (r1.mActivity.getResources().getConfiguration().orientation == 1) goto L_0x00d0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:50:0x00ef, code lost:
        if (r1.mActivity.getResources().getConfiguration().orientation == 2) goto L_0x00d0;
     */
    /* JADX WARNING: Removed duplicated region for block: B:100:0x023c  */
    /* JADX WARNING: Removed duplicated region for block: B:108:0x0261  */
    /* JADX WARNING: Removed duplicated region for block: B:110:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:17:0x0058  */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x005a  */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x009e  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00a7  */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x00aa  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00af  */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00b4  */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x011b  */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x0124  */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x012c  */
    /* JADX WARNING: Removed duplicated region for block: B:61:0x013c A[SYNTHETIC, Splitter:B:61:0x013c] */
    /* JADX WARNING: Removed duplicated region for block: B:92:0x020f  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final void zzt(boolean r21) throws com.google.android.gms.ads.internal.overlay.zzg {
        /*
            r20 = this;
            r1 = r20
            boolean r3 = r1.zzcmz
            r4 = 1
            if (r3 != 0) goto L_0x000c
            android.app.Activity r3 = r1.mActivity
            r3.requestWindowFeature(r4)
        L_0x000c:
            android.app.Activity r3 = r1.mActivity
            android.view.Window r3 = r3.getWindow()
            if (r3 != 0) goto L_0x001c
            com.google.android.gms.ads.internal.overlay.zzg r2 = new com.google.android.gms.ads.internal.overlay.zzg
            java.lang.String r3 = "Invalid activity, no window available."
            r2.<init>(r3)
            throw r2
        L_0x001c:
            boolean r5 = com.google.android.gms.common.util.zzs.isAtLeastN()
            if (r5 == 0) goto L_0x0048
            com.google.android.gms.internal.zzny<java.lang.Boolean> r5 = com.google.android.gms.internal.zzoi.zzbuz
            com.google.android.gms.internal.zzog r6 = com.google.android.gms.internal.zzlc.zzio()
            java.lang.Object r5 = r6.zzd(r5)
            java.lang.Boolean r5 = (java.lang.Boolean) r5
            boolean r5 = r5.booleanValue()
            if (r5 == 0) goto L_0x0048
            com.google.android.gms.ads.internal.zzbt.zzel()
            android.app.Activity r5 = r1.mActivity
            android.app.Activity r6 = r1.mActivity
            android.content.res.Resources r6 = r6.getResources()
            android.content.res.Configuration r6 = r6.getConfiguration()
            boolean r5 = com.google.android.gms.internal.zzaij.zza((android.app.Activity) r5, (android.content.res.Configuration) r6)
            goto L_0x0049
        L_0x0048:
            r5 = r4
        L_0x0049:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r6 = r1.zzcml
            com.google.android.gms.ads.internal.zzap r6 = r6.zzcnu
            r7 = 0
            if (r6 == 0) goto L_0x005a
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r6 = r1.zzcml
            com.google.android.gms.ads.internal.zzap r6 = r6.zzcnu
            boolean r6 = r6.zzaqq
            if (r6 == 0) goto L_0x005a
            r6 = r4
            goto L_0x005b
        L_0x005a:
            r6 = r7
        L_0x005b:
            boolean r8 = r1.zzcms
            if (r8 == 0) goto L_0x0061
            if (r6 == 0) goto L_0x0097
        L_0x0061:
            if (r5 == 0) goto L_0x0097
            r5 = 1024(0x400, float:1.435E-42)
            r3.setFlags(r5, r5)
            com.google.android.gms.internal.zzny<java.lang.Boolean> r5 = com.google.android.gms.internal.zzoi.zzbpl
            com.google.android.gms.internal.zzog r6 = com.google.android.gms.internal.zzlc.zzio()
            java.lang.Object r5 = r6.zzd(r5)
            java.lang.Boolean r5 = (java.lang.Boolean) r5
            boolean r5 = r5.booleanValue()
            if (r5 == 0) goto L_0x0097
            boolean r5 = com.google.android.gms.common.util.zzs.zzanv()
            if (r5 == 0) goto L_0x0097
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r5 = r1.zzcml
            com.google.android.gms.ads.internal.zzap r5 = r5.zzcnu
            if (r5 == 0) goto L_0x0097
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r5 = r1.zzcml
            com.google.android.gms.ads.internal.zzap r5 = r5.zzcnu
            boolean r5 = r5.zzaqv
            if (r5 == 0) goto L_0x0097
            android.view.View r5 = r3.getDecorView()
            r6 = 4098(0x1002, float:5.743E-42)
            r5.setSystemUiVisibility(r6)
        L_0x0097:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r5 = r1.zzcml
            com.google.android.gms.internal.zzaof r5 = r5.zzcnm
            r6 = 0
            if (r5 == 0) goto L_0x00a7
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r5 = r1.zzcml
            com.google.android.gms.internal.zzaof r5 = r5.zzcnm
            com.google.android.gms.internal.zzapu r5 = r5.zzua()
            goto L_0x00a8
        L_0x00a7:
            r5 = r6
        L_0x00a8:
            if (r5 == 0) goto L_0x00af
            boolean r5 = r5.zzfz()
            goto L_0x00b0
        L_0x00af:
            r5 = r7
        L_0x00b0:
            r1.zzcmu = r7
            if (r5 == 0) goto L_0x00f2
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r8 = r1.zzcml
            int r8 = r8.orientation
            com.google.android.gms.internal.zzaip r9 = com.google.android.gms.ads.internal.zzbt.zzen()
            int r9 = r9.zzrg()
            if (r8 != r9) goto L_0x00d4
            android.app.Activity r8 = r1.mActivity
            android.content.res.Resources r8 = r8.getResources()
            android.content.res.Configuration r8 = r8.getConfiguration()
            int r8 = r8.orientation
            if (r8 != r4) goto L_0x00d1
        L_0x00d0:
            r7 = r4
        L_0x00d1:
            r1.zzcmu = r7
            goto L_0x00f2
        L_0x00d4:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r8 = r1.zzcml
            int r8 = r8.orientation
            com.google.android.gms.internal.zzaip r9 = com.google.android.gms.ads.internal.zzbt.zzen()
            int r9 = r9.zzrh()
            if (r8 != r9) goto L_0x00f2
            android.app.Activity r8 = r1.mActivity
            android.content.res.Resources r8 = r8.getResources()
            android.content.res.Configuration r8 = r8.getConfiguration()
            int r8 = r8.orientation
            r9 = 2
            if (r8 != r9) goto L_0x00d1
            goto L_0x00d0
        L_0x00f2:
            boolean r7 = r1.zzcmu
            r8 = 46
            java.lang.StringBuilder r9 = new java.lang.StringBuilder
            r9.<init>(r8)
            java.lang.String r8 = "Delay onShow to next orientation change: "
            r9.append(r8)
            r9.append(r7)
            java.lang.String r7 = r9.toString()
            com.google.android.gms.internal.zzahw.zzby(r7)
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r7 = r1.zzcml
            int r7 = r7.orientation
            r1.setRequestedOrientation(r7)
            com.google.android.gms.internal.zzaip r7 = com.google.android.gms.ads.internal.zzbt.zzen()
            boolean r3 = r7.zza((android.view.Window) r3)
            if (r3 == 0) goto L_0x0120
            java.lang.String r3 = "Hardware acceleration on the AdActivity window enabled."
            com.google.android.gms.internal.zzahw.zzby(r3)
        L_0x0120:
            boolean r3 = r1.zzcms
            if (r3 != 0) goto L_0x012c
            com.google.android.gms.ads.internal.overlay.zzh r3 = r1.zzcmt
            r7 = -16777216(0xffffffffff000000, float:-1.7014118E38)
        L_0x0128:
            r3.setBackgroundColor(r7)
            goto L_0x0131
        L_0x012c:
            com.google.android.gms.ads.internal.overlay.zzh r3 = r1.zzcmt
            int r7 = zzcmk
            goto L_0x0128
        L_0x0131:
            android.app.Activity r3 = r1.mActivity
            com.google.android.gms.ads.internal.overlay.zzh r7 = r1.zzcmt
            r3.setContentView(r7)
            r1.zzcmz = r4
            if (r21 == 0) goto L_0x020f
            com.google.android.gms.internal.zzaol r8 = com.google.android.gms.ads.internal.zzbt.zzem()     // Catch:{ Exception -> 0x0200 }
            android.app.Activity r9 = r1.mActivity     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm     // Catch:{ Exception -> 0x0200 }
            if (r3 == 0) goto L_0x0152
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaqa r3 = r3.zzty()     // Catch:{ Exception -> 0x0200 }
            r10 = r3
            goto L_0x0153
        L_0x0152:
            r10 = r6
        L_0x0153:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm     // Catch:{ Exception -> 0x0200 }
            if (r3 == 0) goto L_0x0163
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm     // Catch:{ Exception -> 0x0200 }
            java.lang.String r3 = r3.zztz()     // Catch:{ Exception -> 0x0200 }
            r11 = r3
            goto L_0x0164
        L_0x0163:
            r11 = r6
        L_0x0164:
            r12 = 1
            r14 = 0
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzala r15 = r3.zzatz     // Catch:{ Exception -> 0x0200 }
            r16 = 0
            r17 = 0
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm     // Catch:{ Exception -> 0x0200 }
            if (r3 == 0) goto L_0x017f
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.ads.internal.zzv r3 = r3.zzbo()     // Catch:{ Exception -> 0x0200 }
            r18 = r3
            goto L_0x0181
        L_0x017f:
            r18 = r6
        L_0x0181:
            com.google.android.gms.internal.zziu r19 = com.google.android.gms.internal.zziu.zzhp()     // Catch:{ Exception -> 0x0200 }
            r13 = r5
            com.google.android.gms.internal.zzaof r3 = r8.zza(r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19)     // Catch:{ Exception -> 0x0200 }
            r1.zzcct = r3     // Catch:{ Exception -> 0x0200 }
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            com.google.android.gms.internal.zzapu r7 = r3.zzua()
            r8 = 0
            r9 = 0
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.ads.internal.gmsg.zzb r10 = r3.zzcnn
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.ads.internal.overlay.zzt r11 = r3.zzcnr
            r12 = 1
            r13 = 0
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm
            if (r3 == 0) goto L_0x01b0
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm
            com.google.android.gms.internal.zzapu r3 = r3.zzua()
            com.google.android.gms.ads.internal.zzw r6 = r3.zzun()
        L_0x01b0:
            r14 = r6
            r15 = 0
            r16 = 0
            r7.zza(r8, r9, r10, r11, r12, r13, r14, r15, r16)
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            com.google.android.gms.internal.zzapu r3 = r3.zzua()
            com.google.android.gms.internal.zzapv r6 = com.google.android.gms.ads.internal.overlay.zze.zzcnd
            r3.zza((com.google.android.gms.internal.zzapv) r6)
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            java.lang.String r3 = r3.url
            if (r3 == 0) goto L_0x01d2
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r6 = r1.zzcml
            java.lang.String r6 = r6.url
            r3.loadUrl(r6)
            goto L_0x01ea
        L_0x01d2:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            java.lang.String r3 = r3.zzcnq
            if (r3 == 0) goto L_0x01f8
            com.google.android.gms.internal.zzaof r6 = r1.zzcct
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            java.lang.String r7 = r3.zzcno
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            java.lang.String r8 = r3.zzcnq
            java.lang.String r9 = "text/html"
            java.lang.String r10 = "UTF-8"
            r11 = 0
            r6.loadDataWithBaseURL(r7, r8, r9, r10, r11)
        L_0x01ea:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm
            if (r3 == 0) goto L_0x021c
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm
            r3.zzb((com.google.android.gms.ads.internal.overlay.zzd) r1)
            goto L_0x021c
        L_0x01f8:
            com.google.android.gms.ads.internal.overlay.zzg r2 = new com.google.android.gms.ads.internal.overlay.zzg
            java.lang.String r3 = "No URL or HTML to display in ad overlay."
            r2.<init>(r3)
            throw r2
        L_0x0200:
            r0 = move-exception
            r2 = r0
            java.lang.String r3 = "Error obtaining webview."
            com.google.android.gms.internal.zzahw.zzb(r3, r2)
            com.google.android.gms.ads.internal.overlay.zzg r2 = new com.google.android.gms.ads.internal.overlay.zzg
            java.lang.String r3 = "Could not obtain webview for the overlay."
            r2.<init>(r3)
            throw r2
        L_0x020f:
            com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel r3 = r1.zzcml
            com.google.android.gms.internal.zzaof r3 = r3.zzcnm
            r1.zzcct = r3
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            android.app.Activity r6 = r1.mActivity
            r3.setContext(r6)
        L_0x021c:
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            r3.zza((com.google.android.gms.ads.internal.overlay.zzd) r1)
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            android.view.ViewParent r3 = r3.getParent()
            if (r3 == 0) goto L_0x0238
            boolean r6 = r3 instanceof android.view.ViewGroup
            if (r6 == 0) goto L_0x0238
            android.view.ViewGroup r3 = (android.view.ViewGroup) r3
            com.google.android.gms.internal.zzaof r6 = r1.zzcct
            android.view.View r6 = r6.getView()
            r3.removeView(r6)
        L_0x0238:
            boolean r3 = r1.zzcms
            if (r3 == 0) goto L_0x0241
            com.google.android.gms.internal.zzaof r3 = r1.zzcct
            r3.zzul()
        L_0x0241:
            com.google.android.gms.ads.internal.overlay.zzh r3 = r1.zzcmt
            com.google.android.gms.internal.zzaof r6 = r1.zzcct
            android.view.View r6 = r6.getView()
            r7 = -1
            r3.addView(r6, r7, r7)
            if (r21 != 0) goto L_0x0256
            boolean r2 = r1.zzcmu
            if (r2 != 0) goto L_0x0256
            r20.zznn()
        L_0x0256:
            r1.zzs(r5)
            com.google.android.gms.internal.zzaof r2 = r1.zzcct
            boolean r2 = r2.zzub()
            if (r2 == 0) goto L_0x0264
            r1.zza((boolean) r5, (boolean) r4)
        L_0x0264:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.ads.internal.overlay.zzd.zzt(boolean):void");
    }

    public final void close() {
        this.zzcmv = 2;
        this.mActivity.finish();
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
    }

    public final void onBackPressed() {
        this.zzcmv = 0;
    }

    public void onCreate(Bundle bundle) {
        this.mActivity.requestWindowFeature(1);
        this.zzcmr = bundle != null ? bundle.getBoolean("com.google.android.gms.ads.internal.overlay.hasResumed", false) : false;
        try {
            this.zzcml = AdOverlayInfoParcel.zzc(this.mActivity.getIntent());
            if (this.zzcml == null) {
                throw new zzg("Could not get info for ad overlay.");
            }
            if (this.zzcml.zzatz.zzdja > 7500000) {
                this.zzcmv = 3;
            }
            if (this.mActivity.getIntent() != null) {
                this.zzcnc = this.mActivity.getIntent().getBooleanExtra("shouldCallOnOverlayOpened", true);
            }
            if (this.zzcml.zzcnu != null) {
                this.zzcms = this.zzcml.zzcnu.zzaqp;
            } else {
                this.zzcms = false;
            }
            if (((Boolean) zzlc.zzio().zzd(zzoi.zzbrz)).booleanValue() && this.zzcms && this.zzcml.zzcnu.zzaqu != -1) {
                new zzj(this, (zzf) null).zzqj();
            }
            if (bundle == null) {
                if (this.zzcml.zzcnl != null && this.zzcnc) {
                    this.zzcml.zzcnl.zzcg();
                }
                if (!(this.zzcml.zzcns == 1 || this.zzcml.zzcnk == null)) {
                    this.zzcml.zzcnk.onAdClicked();
                }
            }
            this.zzcmt = new zzh(this.mActivity, this.zzcml.zzcnt, this.zzcml.zzatz.zzcu);
            this.zzcmt.setId(1000);
            switch (this.zzcml.zzcns) {
                case 1:
                    zzt(false);
                    return;
                case 2:
                    this.zzcmm = new zzi(this.zzcml.zzcnm);
                    zzt(false);
                    return;
                case 3:
                    zzt(true);
                    return;
                default:
                    throw new zzg("Could not determine ad overlay type.");
            }
        } catch (zzg e) {
            zzahw.zzcz(e.getMessage());
            this.zzcmv = 3;
            this.mActivity.finish();
        }
    }

    public final void onDestroy() {
        if (this.zzcct != null) {
            this.zzcmt.removeView(this.zzcct.getView());
        }
        zznk();
    }

    public final void onPause() {
        zzng();
        if (this.zzcml.zzcnl != null) {
            this.zzcml.zzcnl.onPause();
        }
        if (!((Boolean) zzlc.zzio().zzd(zzoi.zzbva)).booleanValue() && this.zzcct != null && (!this.mActivity.isFinishing() || this.zzcmm == null)) {
            zzbt.zzen();
            zzaip.zzh(this.zzcct);
        }
        zznk();
    }

    public final void onRestart() {
    }

    public final void onResume() {
        if (this.zzcml.zzcnl != null) {
            this.zzcml.zzcnl.onResume();
        }
        if (((Boolean) zzlc.zzio().zzd(zzoi.zzbva)).booleanValue()) {
            return;
        }
        if (this.zzcct == null || this.zzcct.isDestroyed()) {
            zzahw.zzcz("The webview does not exist. Ignoring action.");
            return;
        }
        zzbt.zzen();
        zzaip.zzi(this.zzcct);
    }

    public final void onSaveInstanceState(Bundle bundle) {
        bundle.putBoolean("com.google.android.gms.ads.internal.overlay.hasResumed", this.zzcmr);
    }

    public final void onStart() {
        if (!((Boolean) zzlc.zzio().zzd(zzoi.zzbva)).booleanValue()) {
            return;
        }
        if (this.zzcct == null || this.zzcct.isDestroyed()) {
            zzahw.zzcz("The webview does not exist. Ignoring action.");
            return;
        }
        zzbt.zzen();
        zzaip.zzi(this.zzcct);
    }

    public final void onStop() {
        if (((Boolean) zzlc.zzio().zzd(zzoi.zzbva)).booleanValue() && this.zzcct != null && (!this.mActivity.isFinishing() || this.zzcmm == null)) {
            zzbt.zzen();
            zzaip.zzh(this.zzcct);
        }
        zznk();
    }

    public final void setRequestedOrientation(int i) {
        if (this.mActivity.getApplicationInfo().targetSdkVersion >= ((Integer) zzlc.zzio().zzd(zzoi.zzbvx)).intValue()) {
            if (this.mActivity.getApplicationInfo().targetSdkVersion <= ((Integer) zzlc.zzio().zzd(zzoi.zzbvy)).intValue()) {
                if (Build.VERSION.SDK_INT >= ((Integer) zzlc.zzio().zzd(zzoi.zzbvz)).intValue()) {
                    if (Build.VERSION.SDK_INT <= ((Integer) zzlc.zzio().zzd(zzoi.zzbwa)).intValue()) {
                        return;
                    }
                }
            }
        }
        this.mActivity.setRequestedOrientation(i);
    }

    public final void zza(View view, WebChromeClient.CustomViewCallback customViewCallback) {
        this.zzcmp = new FrameLayout(this.mActivity);
        this.zzcmp.setBackgroundColor(ViewCompat.MEASURED_STATE_MASK);
        this.zzcmp.addView(view, -1, -1);
        this.mActivity.setContentView(this.zzcmp);
        this.zzcmz = true;
        this.zzcmq = customViewCallback;
        this.zzcmo = true;
    }

    public final void zza(boolean z, boolean z2) {
        boolean z3 = false;
        boolean z4 = ((Boolean) zzlc.zzio().zzd(zzoi.zzbpm)).booleanValue() && this.zzcml != null && this.zzcml.zzcnu != null && this.zzcml.zzcnu.zzaqw;
        if (z && z2 && z4) {
            new zzyn(this.zzcct, "useCustomClose").zzbm("Custom close has been disabled for interstitial ads in this ad slot.");
        }
        if (this.zzcmn != null) {
            zzo zzo = this.zzcmn;
            if (z2 && !z4) {
                z3 = true;
            }
            zzo.zza(z, z3);
        }
    }

    public final void zzbd() {
        this.zzcmz = true;
    }

    public final void zzk(IObjectWrapper iObjectWrapper) {
        if (((Boolean) zzlc.zzio().zzd(zzoi.zzbuz)).booleanValue() && zzs.isAtLeastN()) {
            zzbt.zzel();
            if (zzaij.zza(this.mActivity, (Configuration) zzn.zzy(iObjectWrapper))) {
                this.mActivity.getWindow().addFlags(1024);
                this.mActivity.getWindow().clearFlags(2048);
                return;
            }
            this.mActivity.getWindow().addFlags(2048);
            this.mActivity.getWindow().clearFlags(1024);
        }
    }

    public final void zzng() {
        if (this.zzcml != null && this.zzcmo) {
            setRequestedOrientation(this.zzcml.orientation);
        }
        if (this.zzcmp != null) {
            this.mActivity.setContentView(this.zzcmt);
            this.zzcmz = true;
            this.zzcmp.removeAllViews();
            this.zzcmp = null;
        }
        if (this.zzcmq != null) {
            this.zzcmq.onCustomViewHidden();
            this.zzcmq = null;
        }
        this.zzcmo = false;
    }

    public final void zznh() {
        this.zzcmv = 1;
        this.mActivity.finish();
    }

    public final boolean zzni() {
        this.zzcmv = 0;
        if (this.zzcct == null) {
            return true;
        }
        boolean zzuf = this.zzcct.zzuf();
        if (!zzuf) {
            this.zzcct.zza("onbackblocked", (Map<String, ?>) Collections.emptyMap());
        }
        return zzuf;
    }

    public final void zznj() {
        this.zzcmt.removeView(this.zzcmn);
        zzs(true);
    }

    /* access modifiers changed from: package-private */
    public final void zznl() {
        if (!this.zzcnb) {
            this.zzcnb = true;
            if (this.zzcct != null) {
                this.zzcmt.removeView(this.zzcct.getView());
                if (this.zzcmm != null) {
                    this.zzcct.setContext(this.zzcmm.zzaiq);
                    this.zzcct.zzah(false);
                    this.zzcmm.parent.addView(this.zzcct.getView(), this.zzcmm.index, this.zzcmm.zzcng);
                    this.zzcmm = null;
                } else if (this.mActivity.getApplicationContext() != null) {
                    this.zzcct.setContext(this.mActivity.getApplicationContext());
                }
                this.zzcct = null;
            }
            if (this.zzcml != null && this.zzcml.zzcnl != null) {
                this.zzcml.zzcnl.zzcf();
            }
        }
    }

    public final void zznm() {
        if (this.zzcmu) {
            this.zzcmu = false;
            zznn();
        }
    }

    public final void zzno() {
        this.zzcmt.zzcnf = true;
    }

    public final void zznp() {
        synchronized (this.zzcmw) {
            this.zzcmy = true;
            if (this.zzcmx != null) {
                zzaij.zzdfn.removeCallbacks(this.zzcmx);
                zzaij.zzdfn.post(this.zzcmx);
            }
        }
    }
}
